﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BetterWebBooking
{
    public partial class Stations : System.Web.UI.Page
    {
        static BetterServiceReference.IBookingService bookObj = new BetterServiceReference.BookingServiceClient();
            
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                StationListBox.DataSource = bookObj.GetAllStations();
                StationListBox.DataTextField = "StationName";
                StationListBox.DataValueField = "StationId";
                StationListBox.DataBind();
            }
        }

        protected void StationListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            //BetterServiceReference.Station selected = (BetterServiceReference.Station)StationListBox.SelectedValue;
            int index = StationListBox.SelectedIndex;
            IList<BetterServiceReference.Station> stationList = bookObj.GetAllStations();
            BetterServiceReference.Station stationObj = stationList[index];
            StationNameTextBox.Text = stationObj.StationName;
            StationAddressTextBox.Text = stationObj.StationAddress;
            StationCityTextBox.Text = stationObj.City;
            StationZipTextBox.Text = stationObj.ZipCode.ToString();
        }

    }
}